
import api from '../../http/api.js'
export default {
namespaced: true,
  state: {
    roomData:{

    },
   work:'',
   free:'',
   clean:''

  },
  mutations: {
    
    saveroomData(state,newData){
    state.roomData=newData
    },
    work(state,newData){
      state.work= newData.list.filter(item=>item.roomState=='1').length

    },
    free(state,newData){
      state.free= newData.list.filter(item=>item.roomState=='0').length
    },
    clean(state,newData){
      state.clean= newData.list.filter(item=>item.roomState=='2').length
    },

  },
  actions: {
    
  async getAllroom(context){
      const data =await api.room.getAllroom()
   
      if(data.data.stateCode){
        context.commit('saveroomData',data.data.data)
        context.commit('work',data.data.data)
        context.commit('free',data.data.data)
        context.commit('clean',data.data.data)
      
      }
    },
    

  }
}
